#include<bits/stdc++.h>
using namespace std;
int D[100005];
int main() {
  // freopen("in.txt","r",stdin);
  // freopen("out.txt","w",stdout);
  for(int i=1; i!=100000; ++i) {
    int sum=i;
    int tmp=i;
    while(tmp) {sum+=tmp%10;tmp/=10;}
    if(i<D[sum] || D[sum]==0) {
      D[sum] = i;
    }
  }
  // int T;
  // while(cin>>T) {
  //   cout<<D[T]<<endl;
  // }
  int times;
  cin >> times;
  for(int k=0; k<times; ++k) {
    int get;
    cin >> get;
    cout << D[get] << endl;
  }
  // cout << "CPU time: "<<(double)clock()/CLOCKS_PER_SEC<<"s"<<endl;
  return 0;
}
